<?php
namespace Admin\Model;
use Think\Model;

class PictureCatModel extends Model {
    
    
    public function all(){
        $map['state']=1;
        $arr = $this->where($map)->select();
        return $this->list_level($arr,$pid=0,$level=0);
    }
   
    public function list_level($arr,$pid=0,$level=0){
        
        static $data = array();
        foreach($arr as $k => $v){
            if($v['pid'] == $pid){
                $v['level'] = $level;
                $data[] = $v;
                $this->list_level($arr,$v['id'],$level+1);
            }
        }
        return $data;
    }
  
     
}